package com.markyao.controller.recos;

import com.markyao.recos.conf.RecosConfService;
import com.markyao.service.db.ConfigInfoService;
import com.markyao.service.db.HisConfigService;
import com.markyao.vo.ConfParam;
import com.markyao.vo.ConfigInfoVo;
import com.markyao.vo.Result;
import com.markyao.vo.pojo.ConfigInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/recos/group")
public class RecosGroupConfigController {

    @Autowired
    ConfigInfoService configInfoService;
    @Autowired
    HisConfigService hisConfigService;
    @Autowired
    RecosConfService recosConfService;

    @PostMapping("insertConfigInfo")
    public Result insertConfigInfo(@RequestBody ConfigInfoVo configInfo){
        return configInfoService.insert(configInfo);
    }

    @GetMapping("deleteConfigInfo/{id}")
    public Result deleteConfigInfo(@PathVariable Long id){
        return configInfoService.delete(id);
    }


    @PostMapping("updateConfigInfo")
    public Result updateConfigInfo(@RequestBody ConfigInfoVo configInfov){
        return configInfoService.update(configInfov);
    }
    @PostMapping("deleteConfigInfos")
    public Result deleteConfigInfos(@RequestBody String[] ids){
        return configInfoService.deletes(ids);
    }


    @GetMapping("rollback/{id}")
    public Result rollback(@PathVariable String id){
        return hisConfigService.rollback(id);
    }
    @PostMapping("deleteHisConfig")
    public Result deleteHisConfig(@RequestBody String []ids){
        return hisConfigService.deletes(ids);
    }
    @GetMapping("refreshOk/{appName}")
    public Result refreshOk(@PathVariable String appName){
        return recosConfService.refreshOk(appName);
    }
    @PostMapping("refreshConf")
    public Result refreshConf(@RequestBody ConfParam confParam){
        return recosConfService.refreshConf(confParam);
    }
    @GetMapping("registDataIdAndAppName/{appName}/{dataId}")
    public Result registDataIdAndAppName(@PathVariable String appName,@PathVariable String dataId){
        return recosConfService.registDataIdAndAppName(appName,dataId);
    }

}
